%{open Ast %}

%token<string> ID

/* Primitive types */
%token<int> INT
%token<bool> BOOLEAN
%token<float> FLOAT
%token<string> STRING

/* Grouping symbols */
%token LPAREN RPAREN RCURL LCURL RBRACE LBRACE BAR

/* Punctuation */
%token COMMA DOT COLON ASSIGN

/* Arithmetic Operators */
%token PLUS MINUS TIMES DIVIDE MOD

/* Boolean Operators */
%token NOT AND OR

/* Inc Operators */
%token INCREMENT DECREMENT

/* Comparison Operators */
%token NEQ EQ LT GT LEQ GEQ

/* Update Operators */
%token PLUSEQ MINUSEQ TIMESEQ SLASHEQ

/* Separators */
%token EOL EOF

/* Keywords */
%token IF ELSEIF ELSE WHILE FOR RETURN RULES

/* Built in functions */
%token CAST PLAY INPUT OUTPUT

/* Type keywords */
%token INTTYPE FLOATTYPE STRINGTYPE BOOLTYPE

%left NOT
%right ASSIGN
%left EQ NEQ
%left LT GT LEQ GEQ
%left PLUS MINUS
%left TIMES DIVIDE MOD

%start program
%type <Ast.program> program

%%

expression:
 	INT	{Integer($1)}
|	identifier {IdExpr($1)}
	
identifier:
    ID {Identifier($1)}

assignment:
	identifier ASSIGN expression 	{Assignment($1, $3)}

program:
	assignment 				{[$1]}
|	program EOL assignment 	{($3::$1)}


